var formidable = require('formidable');
var http = require("http");
/*provide methods which allow us to extract the different parts of URL*/
var url = require('url');

function start(route, handle) {
    function onRequest(request, response) {
        
        var pathname = url.parse(request.url).pathname
        var postData = '';
        
        console.log("request for " + pathname + ' received.');
        route(handle, pathname, response, request)
    }

    http.createServer(onRequest).listen(8888);
    console.log("Server has started at port: 8888");
}

exports.start = start;